#include <iostream>
#include <vector>
using namespace std;

const int kMaxN = 1e5 + 10;
const int kMaxA = 1e5 + 1;

int num[kMaxA];
vector<int> prime;
int f[kMaxA];

void Pre() {
  for (int i = 2; i < kMaxA; i++) {
    if (num[i] == 0) {
      prime.push_back(i);
      num[i] = i;
    }
    for (int j : prime) {
      if (i * j >= kMaxA) {
        break;
      }
      num[i * j] = j;
      if (i % j == 0) {
        break;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, ans = 0;

  Pre();
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, tmp = 0;

    cin >> a;

    for (int x = a; x > 1; x /= num[x]) {
      tmp = max(tmp, f[num[x]]);
    }
    for (int x = a; x > 1; x /= num[x]) {
      f[num[x]] = tmp + 1;
    }
    ans = max(ans, tmp + 1);
  }
  cout << ans << "\n";
  return 0;
}